<template>
  <view class="section">
    <PronunciationTest
      v-if="wordData"
      :wordData="wordData"
      :showWordInfo="false"
      :showResultType="'2'"
      :passCount="5"
      @complete="completeWord"
      @save="saveWordRecord"
      :key="componentKey"
    ></PronunciationTest>
  </view>
</template>

<script>
import { saveWordLearningRecord } from "@/api/sync";
export default {
  components: {},
  props: {
    wordData: {
      type: Object,
      default: null,
    },
  },
  data() {
    return {
      isCompleted: false,
      componentKey: 0,
    };
  },
  mounted() {},
  methods: {
    completeWord(isPass, recorderCount, passCount) {
      if (isPass || recorderCount === passCount) {
        this.isCompleted = true;
      }
    },
    saveWordRecord(score, isPass) {
      let params = {
        score: score,
        pass: isPass ? 1 : 0,
        step: "2",
        type: "dclx",
        wordId: this.wordData.id,
      };
      saveWordLearningRecord(params);
    },
  },
};
</script>

<style lang="scss" scoped>
@import "./WordStep2";
</style>
